package com.example.zhou.base;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.bumptech.glide.BitmapRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.model.GlideUrl;
import com.example.zhou.application.MyApplication;
import com.example.zhou.receiver.ConnectivityReceiver;
import com.example.zhou.zhihunews.R;

import butterknife.ButterKnife;

/**
 * Created by 11065 on 2016/10/24.
 */

public class BaseActivity extends AppCompatActivity implements ConnectivityReceiver.ConnectivityReceiverListener {
    public BitmapRequestBuilder<GlideUrl, Bitmap> requestBuilder;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestBuilder = Glide.with(this)
                .from(GlideUrl.class)
                .asBitmap()
                .centerCrop()
                .error(R.mipmap.ic_launcher)
                .diskCacheStrategy(DiskCacheStrategy.ALL);
        MyApplication.getInstance().setConnectivityListener(this);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onNetworkConnectionChanged(boolean isConnected) {
        Toast.makeText(this, "网络连接中断", Toast.LENGTH_SHORT).show();
    }
}
